
//
//  BaseTableViewController.swift
//  weibo
//
//  Created by 陈经纬 on 16/7/18.
//  Copyright © 2016年 陈经纬. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController {



        //定义用户登录状态
        var isLogin = false
        
        //访客视图
        var visitView : ViewLogin?
        
        override func loadView(){// 判断用户是否登录, 如果没有登录就显示访客界面, 如果已经登录就显示tableview
            isLogin ? super.loadView() : setupVisitView()
            
        }
        
        //设置访客视图
        func setupVisitView(){
            
            visitView = ViewLogin.visitorView()
           view = visitView
            
            
            visitView?.register.addTarget(self, action: #selector(BaseTableViewController.registor), forControlEvents: UIControlEvents.TouchUpInside)
            visitView?.login.addTarget(self, action: #selector(BaseTableViewController.login), forControlEvents: UIControlEvents.TouchUpInside)
            
            //设置导航条左右上角的按钮
            navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(BaseTableViewController.registor))
            navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(BaseTableViewController.login))
        }
    //注册事件
    func registor()  {
        JWLog("")
        
    }
    //登录事件
    func login()  {
        JWLog("")
    }

}